<?php if (!defined('THINK_PATH')) exit(); /*a:2:{s:74:"/www/wwwroot/zaozao/public/../application/admin/view/water/water_list.html";i:1596440586;s:59:"/www/wwwroot/zaozao/application/admin/view/public/head.html";i:1597211856;}*/ ?>
<!DOCTYPE html>
<html>
  
  <head>
    <meta charset="UTF-8">
    <title>支付宝生活缴费系统</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
    <link rel="stylesheet" href="/static/admin/css/font.css">
	<link rel="stylesheet" href="/static/admin/css/xadmin.css">
	<!--<link rel="stylesheet" href="/static/admin/css/bootstrap.min.css">
	<link rel="stylesheet" href="/static/admin/js/bootstrap.min.js">-->
	
    <script src="/static/admin/js/jquery.min.js"></script>
    <script src="/static/admin/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="/static/admin/js/xadmin.js"></script>
  </head>
  
  <body>
    <div class="x-nav">
      <span class="layui-breadcrumb">
        <a><cite>后台管理</cite></a>
        <a><cite>物业管理系统</cite></a>
        <a><cite>水费报表</cite></a>
      </span>
      <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);" title="刷新">
        <i class="layui-icon" style="line-height:30px">ဂ</i></a>
    </div>
    <div class="x-body">
        <div class="layui-row">
            <form class="layui-form layui-col-md12 x-so"  method="get" action="<?php echo url("","",true,false);?>">
              <div class="layui-input-inline">
                <select name="community_id" lay-filter="community_id" id="community_id">
                  <option value="">所属小区</option>
                  <?php foreach($communitylist as $name): ?>
                  <option value="<?php echo $name['community_id']; ?>" <?php if(isset($community_id)): if($community_id == $name['community_id']): ?>selected<?php endif; endif; ?>><?php echo $name['community_name']; ?></option>
                  <?php endforeach; ?>
                </select>
              </div>
              <div class="layui-input-inline">
                <select name="group" id="group" lay-filter="group">
                  <option value="">组团</option>
                  <?php if(isset($groups)): foreach($groups as $gro): ?>
                    <option value="<?php echo $gro; ?>" <?php if(isset($group)): if($gro == $group): ?>selected<?php endif; endif; ?>><?php echo $gro; ?></option>
                  <?php endforeach; endif; ?>
                </select>
              </div>
              <div class="layui-input-inline">
                <select name="building" id="building" lay-filter="building">
                  <option value="">所属楼栋</option>
                  <?php if(isset($buildings)): foreach($buildings as $build): ?>
                    <option value="<?php echo $build; ?>" <?php if(isset($building)): if($build == $building): ?>selected<?php endif; endif; ?>><?php echo $build; ?></option>
                  <?php endforeach; endif; ?>
                </select>
              </div>
              <div class="layui-input-inline">
                <select name="unit" id="unit"  lay-filter="unit">
                  <option value="">所属单元</option>
                  <?php if(isset($units)): foreach($units as $uni): ?>
                    <option value="<?php echo $uni; ?>" <?php if(isset($unit)): if($uni == $unit): ?>selected<?php endif; endif; ?>><?php echo $uni; ?></option>
                  <?php endforeach; endif; ?>
                </select>
              </div>
              <div class="layui-input-inline">
                <select name="room" id="room">
                  <option value="">所属房间号</option>
                  <?php if(isset($rooms)): foreach($rooms as $roo): ?>
                    <option value="<?php echo $roo; ?>" <?php if(isset($room)): if($roo == $room): ?>selected<?php endif; endif; ?>><?php echo $roo; ?></option>
                  <?php endforeach; endif; ?>
                </select>
              </div>
              <div class="layui-input-inline">
                <select name="status">
                  <option value="">状态</option>
                  <option value="1" <?php if(isset($status)): if($status == '1'): ?>selected<?php endif; endif; ?>>已生成账单</option>
                  <option value="2" <?php if(isset($status)): if($status == '2'): ?>selected<?php endif; endif; ?>>未生成账单</option>
                </select>
              </div>
              <button class="layui-btn"  lay-submit="" lay-filter="sreach"><i class="layui-icon">&#xe615;</i></button>
            </form>
          </div>
      <xblock>
        <button class="layui-btn layui-btn-danger" onclick="x_admin_show('添加水费','<?php echo url('waterAdd'); ?>',600,600)"><i class="layui-icon"></i>添加水费</button>
        <button class="layui-btn " onclick="x_admin_show('批量导入','<?php echo url('admin/Water/waterExcel'); ?>',600,400)"><i class="layui-icon"></i>批量导入</button>
        <button class="layui-btn layui-btn-danger" onclick="waterExportExcel('<?php echo $export; ?>')"><i class="layui-icon"></i>批量导出</button>
        <button class="layui-btn" onclick="waterBill()"><i class="layui-icon"></i>上传账单</button>
        <button class="layui-btn layui-btn-danger" onclick="delAll()"><i class="layui-icon"></i>批量删除</button>

        <span class="x-right" style="line-height:40px">共有数据：<?php echo $number; ?> 条</span>
      </xblock>
      <table class="layui-table" id="table">
        <thead  style="text-align:center;">
          <tr>
            <th>
              <div class="layui-unselect header layui-form-checkbox" lay-skin="primary"><i class="layui-icon">&#xe605;</i></div>
            </th>
            <th style="text-align:center; font-size: 16px;">物业名称</th>
            <th style="text-align:center; font-size: 16px;">完整门牌号</th>
            <th style="text-align:center; font-size: 16px;">业主姓名</th>
            <th style="text-align:center; font-size: 16px;">上期吨数</th>
            <th style="text-align:center; font-size: 16px;">本期吨数</th>
            <th style="text-align:center; font-size: 16px;">上期用量</th>
            <th style="text-align:center; font-size: 16px;">本期用量</th>
            <th style="text-align:center; font-size: 16px;">水费单价</th>
            <th style="text-align:center; font-size: 16px;">总金额</th>
            <th style="text-align:center; font-size: 16px;">抄表员</th>
            <th style="text-align:center; font-size: 16px;">抄表时间</th>
            <th style="text-align:center; font-size: 16px;">状态</th>
          </tr>
        </thead>
        <tbody style="text-align:center;">
            <?php foreach($water as $lis): ?>
            <tr>
              <td style="text-align: center;">
                <div class="layui-unselect layui-form-checkbox" lay-skin="primary" data-id='<?php echo $lis['id']; ?>'><i class="layui-icon">&#xe605;</i></div>
              </td>
              <td style="text-align: center;"><?php echo $lis['community_id']; ?></td>
              <td style="text-align: center;"><?php echo $lis['room_address']; ?></td>
              <td style="text-align: center;"><?php echo $lis['owner_name']; ?></td>
              <td style="text-align: center;"><?php echo $lis['upper_stage']; ?></td>
              <td style="text-align: center;"><?php echo $lis['book_stage']; ?></td>
              <td style="text-align: center;"><?php echo $lis['upper_use']; ?></td>
              <td style="text-align: center;"><?php echo $lis['book_use']; ?></td>
              <td style="text-align: center;"><?php echo $lis['unit_price']; ?></td>
              <td style="text-align: center;"><?php echo $lis['money']; ?></td>
              <td style="text-align: center;"><?php echo $lis['meter_reader']; ?></td>
              <td style="text-align: center;"><?php echo $lis['time']; ?></td>
              <td style="text-align: center;">
                  <?php if($lis['status'] == '2'): ?>
                      未生成账单
                  <?php else: ?>
                      已生成账单
                  <?php endif; ?>
              </td>
            </tr>
            <?php endforeach; ?>
        </tbody>
      </table>
      <div class="page">
        <div id="page">
            <?php echo $waterinfo->render(); ?>
        </div>
      </div>

    </div>
    <script>

      layui.use('laydate', function(){
        var laydate = layui.laydate;
        
        //执行一个laydate实例
        laydate.render({
          elem: '#start' //指定元素
        });

        //执行一个laydate实例
        laydate.render({
          elem: '#end' //指定元素
        });
      });

      //批量导出
      function waterExportExcel(exportid){
        var datas = $('#table tbody td .layui-form-checked')
        var ids = []
        datas.each(function(index, element){
          var id = $(this).data('id')
          ids.push(id)
        })

        var str = ids.join(',');
        var count = ids.length
        var url = "<?php echo url('admin/Water/waterExportExcel'); ?>?id=" + str +'&export=' + exportid
        layer.open({
          type: 2,
          title: '批量导出账单',
          shadeClose: true,
          shade: 0.8,
          area: ['80%', '95%'],
          content: url //iframe的url
        }); 
      }

      //上传账单
      function waterBill () {
        var datas = $('#table tbody td .layui-form-checked')
        var ids = []
        datas.each(function(index, element){
          var id = $(this).data('id')
          ids.push(id)
        })

        var str = ids.join(',');
        var count = ids.length
        layer.confirm('你确定要上传这'+ count + '项吗', function(){
          $.post('<?php echo url("admin/Water/waterBill"); ?>', { id: str}, function(r){
            if (r.info) {
              layer.msg(r.info)
              location.reload()
            }else{
              location.reload()
            }
          })
        })
      }
      
      //批量删除
      function delAll () {
        var datas = $('#table tbody td .layui-form-checked')
        var ids = []
        datas.each(function(index, element){
          var id = $(this).data('id')
          ids.push(id)
        })

        var str = ids.join(',');
        var count = ids.length
        layer.confirm('你确定要删除这'+ count + '项吗', function(){
          $.post('<?php echo url("admin/Water/waterDel"); ?>', { id: str}, function(r){
            if (r.info) {
              layer.msg(r.info)
              location.reload()
            }else{
              layer.msg(r.error)
            }
          })
        })
      }

    </script>
<script>
  layui.use(['form'], function() {
      var form = layui.form
      form.on('select(community_id)', function(f){
          var url = "<?php echo url('admin/Roominfo/fetchdata'); ?>"
          $.post(url, {community_id: f.value, type: 1}, function(data) {
              $('#group').html("")
              var option = "<option value=''>所有组团</option>"
              $('#group').append(option)
              for (var i = 0; i < data.length; i++) {
              option = "<option value='" + data[i] + "'>" + data[i] + "</option>"
              $('#group').append(option)
              }
              
              form.render('select')
          })
          
          $('#community_id').data('community_id', f.value)
      })

      form.on('select(group)', function(f){
          var data_community = $('#community_id').data('community_id')
          var get_community = "<?php if (isset($community_id)) { echo $community_id;}?>"
          var community_id = typeof data_community === 'undefined' ? get_community : data_community
          var url = "<?php echo url('admin/Roominfo/fetchdata'); ?>"
          $.post(url, {community_id: community_id, group: f.value, type: 2}, function(data) {
              $('#building').html("")
              var option = "<option value=''>所有楼栋</option>"
              $('#building').append(option)
              for (var i = 0; i < data.length; i++) {
                  option = "<option value='" + data[i] + "'>" + data[i] + "</option>"
                  $('#building').append(option)
              }
              $('#group').data('group', f.value)
              form.render('select')
          })
      })

      form.on('select(building)', function(f){
          var data_community = $('#community_id').data('community_id')
          var get_community = "<?php if (isset($community_id)) { echo $community_id;}?>"
          var community_id = typeof data_community === 'undefined' ? get_community : data_community

          var data_group = $('#group').data('group')
          var get_group = "<?php if (isset($group)) { echo $group;}?>"
          var group = typeof data_group === 'undefined' ? get_group : data_group

          var url = "<?php echo url('admin/Roominfo/fetchdata'); ?>"
          $.post(url, {building: f.value, community_id: community_id, group: group, type: 3}, function(data) {
          $('#unit').html("")
          var option = "<option value=''>所有单元</option>"
          $('#unit').append(option)
          for (var i = 0; i < data.length; i++) {
              option = "<option value='" + data[i] + "'>" + data[i] + "</option>"
              $('#unit').append(option)
          }
          $('#building').data('building', f.value)
          form.render('select')
          })
      })

      form.on('select(unit)', function(f){
          var data_community = $('#community_id').data('community_id')
          var get_community = "<?php if (isset($community_id)) { echo $community_id;}?>"
          var community_id = typeof data_community === 'undefined' ? get_community : data_community

          var data_group = $('#group').data('group')
          var get_group = "<?php if (isset($group)) { echo $group;}?>"
          var group = typeof data_group === 'undefined' ? get_group : data_group

          var data_building = $('#building').data('building')
          var get_building = "<?php if (isset($building)) { echo $building;}?>"
          var building = typeof data_building === 'undefined' ? get_building : data_building
  
          var url = "<?php echo url('admin/Roominfo/fetchdata'); ?>"
          $.post(url, {unit: f.value, community_id: community_id, group: group, building: building, type: 4}, function(data) {
          $('#room').html("")
          var option = "<option value=''>所有房间</option>"
          $('#room').append(option)
          for (var i = 0; i < data.length; i++) {
              option = "<option value='" + data[i] + "'>" + data[i] + "</option>"
              $('#room').append(option)
          }
          $('#unit').data('unit', f.value)
          form.render('select')
          })
      })

  })
</script>
    <script>var _hmt = _hmt || []; (function() {
        var hm = document.createElement("script");
        hm.src = "https://hm.baidu.com/hm.js?b393d153aeb26b46e9431fabaf0f6190";
        var s = document.getElementsByTagName("script")[0];
        s.parentNode.insertBefore(hm, s);
      })();
    </script>

  </body>

</html>